home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / infoserv / www / cern / dev / scott.Z / scott / WWW / NextStep / Implementation / old / tcp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-23  |  5.0 KB  |  182 lines

  1. /*    System-system differences for TCP include files and macros     tcp.h
  2. **    ===========================================================
  3. **
  4. **
  5. **    This file includes for each system, the files necessary for
  6. **    network and file I/O
  7. **
  8. **  History:
  9. **    22 Feb 91    Written (TBL) as part of the WWW project.
  10. */
  11.  
  12. #define NETCLOSE close        /* Routine to close a TCP-IP socket        */
  13. #define NETREAD  read        /* Routine to read from a TCP-IP socket    */
  14. #define NETWRITE write        /* Routine to write to a TCP-IP socket    */
  15.  
  16. /*    On the NeXT, there's a little package of include files.
  17. */
  18. #ifdef NeXT
  19. #include <libc.h>        /* NeXT has all this packaged up */
  20. #define ntohs(x) (x)
  21. #define htons(x) (x)
  22. #include <sys/errno.h>        /* Get ECONNRESET etc */
  23. #define SELECT            /* Is supported ok */
  24. #define INCLUDES_DONE
  25. extern int errno;
  26.  
  27. #else                /* Not NeXT */
  28. #include <stdio.h>
  29.  
  30. /*    MVS is compiled as for VM. MVS has no unix-style I/O
  31. **    The command line compile options seem to come across in
  32. **    lower case.
  33. **
  34. **    See aslo lots of VM stuff lower down.
  35. */
  36. #ifdef mvs
  37. #define MVS
  38. #endif
  39.  
  40. #ifdef MVS
  41. #define VM
  42. #endif
  43.  
  44. /*    VM doesn't have a built-in predefined token, so we cheat: */
  45. #ifdef __STDIO__
  46. #define VM
  47. #else
  48. #include <string.h>        /* For bzero etc - not NeXT or VM */
  49. #endif
  50. #define SELECT            /* Handle >1 channel if we can.        */
  51. #endif                /* Not NeXT */
  52.  
  53.  
  54. /*    Under VMS, there are many versions of TCP-IP. Define one if you
  55. **    do not use Digital's UCX product:
  56. **
  57. **        UCX        DEC's "Ultrix connection" (default)
  58. **        WIN_TCP        From Wollongong, now GEC software.
  59. **        MULTINET    From SRI, now from TGV Inv.
  60. **
  61. **    The second two do not interfere with the unix i/o library, and so they
  62. **    need special calls to read, write and close sockets. In these cases the
  63. **    socket number is a VMS channel number, so we make the HORRIBLE
  64. **    assumption that a channel number will be greater than 10 but a
  65. **    unix file descriptor less than 10.
  66. */
  67. #ifdef vms
  68. #ifdef WIN_TCP
  69. #undef NETREAD
  70. #undef NETWRITE
  71. #undef NETCLOSE
  72. #define NETREAD(s,b,l)    ((s)>10 ? netread((s),(b),(l)) : read((s),(b),(l)))
  73. #define NETWRITE(s,b,l)    ((s)>10 ? netwrite((s),(b),(l)) : write((s),(b),(l)))
  74. #define NETCLOSE(s)     ((s)>10 ? netclose(s) : close(s))
  75. #endif
  76.  
  77. #ifdef MULTINET
  78. #undef NETCLOSE
  79. #undef NETREAD
  80. #undef NETWRITE
  81. #define NETREAD(s,b,l)    ((s)>10 ? socket_read((s),(b),(l)) : read((s),(b),(l)))
  82. #define NETWRITE(s,b,l)    ((s)>10 ? socket_write((s),(b),(l)) : \
  83.                 write((s),(b),(l)))
  84. #define NETCLOSE(s)     ((s)>10 ? socket_close(s) : close(s))
  85. #endif
  86.  
  87. /*    Certainly this works for UCX:    @@@
  88. */
  89. #include types
  90. #include errno
  91. #include time
  92. #include string
  93. #include stdio
  94. #include file
  95. #include unixio
  96.  
  97. #define INCLUDES_DONE
  98.  
  99. #include socket
  100. #include in
  101. #include inet
  102. #include netdb
  103. #define TCP_INCLUDES_DONE
  104.  
  105. #endif    /* vms */
  106.  
  107.  
  108. /*    IBM VM/CMS or MVS
  109. **    -----------------
  110. **
  111. **    Note:    All files must have lines <= 80 characters
  112. **
  113. **    Under VM, compile with "DEF=VM"
  114. **
  115. **    Under MVS, compile with "NOMAR DEF(MVS)" to get rid of 72 char margin
  116. **      System include files TCPIP and COMMMAC neeed line number removal(!)
  117. */
  118.  
  119. #ifdef VM            /* or MVS -- see above. */
  120. #define NOT_ASCII        /* char type is not ASCII */
  121. #define NO_UNIX_IO        /* Unix I/O routines are not supported */
  122. #define SHORT_NAMES        /* 8 character uniqueness for globals */
  123. #include <manifest.h>                                                           
  124. #include <bsdtypes.h>                                                           
  125. #include <stdefs.h>                                                             
  126. #include <socket.h>                                                             
  127. #include <in.h>
  128. #include <netdb.h>                                                                 
  129. #include <errno.h>        /* independent */
  130. extern char asciitoebcdic[], ebcdictoascii[];
  131. #define TOASCII(c)   (c=='\n' ?  10  : ebcdictoascii[c])
  132. #define FROMASCII(c) (c== 10  ? '\n' : asciitoebcdic[c])                                   
  133. #include <bsdtime.h>
  134. #include <string.h>                                                            
  135. #define INCLUDES_DONE
  136. #define TCP_INCLUDES_DONE
  137. #endif
  138.  
  139. /*    Regular BSD unix versions: */
  140.  
  141. #ifndef INCLUDES_DONE
  142. #include <sys/types.h>
  143. /* #include <streams/streams.h>            not ultrix */
  144. #include <string.h>
  145. #include <stdio.h>
  146. #include <errno.h>        /* independent */
  147. #include <sys/time.h>        /* independent */
  148. #include <sys/stat.h>
  149. #include <sys/param.h>
  150. #include <sys/file.h>        /* For open() etc */
  151. #endif    /* Normal includes */
  152.  
  153.  
  154. /*    Default include files for TCP
  155. */
  156. #ifndef TCP_INCLUDES_DONE
  157. #include <sys/socket.h>
  158. #include <netinet/in.h>
  159. #include <arpa/inet.h>        /* Must be after netinet/in.h */
  160. #include <netdb.h>
  161. #endif    /* TCP includes */
  162.  
  163.  
  164. /*    Default macros for manipulating masks for select()
  165. */
  166. #ifndef FD_SET
  167. typedef unsigned int fd_set;
  168. #define FD_SET(fd,pmask) (*(pmask)) |=  (1<<(fd))
  169. #define FD_CLR(fd,pmask) (*(pmask)) &= ~(1<<(fd))
  170. #define FD_ZERO(pmask)   (*(pmask))=0
  171. #define FD_ISSET(fd,pmask) (*(pmask) & (1<<(fd)))
  172. #endif
  173.  
  174.  
  175. /*    Default macros for converting characters
  176. **
  177. */
  178. #ifndef TOASCII
  179. #define TOASCII(c) (c)
  180. #define FROMASCII(c) (c)                                   
  181. #endif
  182.